#ifndef _UI_TOP_STATUS_BAR_HPP
#define _UI_TOP_STATUS_BAR_HPP

// 状态栏图标
lv_label_t *statusBarInfo;
lv_label_t *statusBarIconLabelWifi;
lv_label_t *statusBarIconLabelWs;
lv_label_t *statusBarCallSign;

void statusBarInit(lv_obj_t *p) {
	LVMT;
	statusBarIconLabelWifi = lv_label_create(p);
	lv_obj_set_style_text_color(statusBarIconLabelWifi, LV_COLOR_FONT_2, 0);
	lv_obj_set_style_text_font(statusBarIconLabelWifi, CFONT, 0);
	lv_obj_set_pos(statusBarIconLabelWifi, 10, 1);
	lv_label_set_text(statusBarIconLabelWifi,  ICON_WIFI);

	statusBarIconLabelWs = lv_label_create(p);
	lv_obj_set_style_text_color(statusBarIconLabelWs, LV_COLOR_FONT_2, 0);
	lv_obj_set_style_text_font(statusBarIconLabelWs, CFONT, 0);
	lv_obj_set_pos(statusBarIconLabelWs, 32, 2);
	lv_label_set_text(statusBarIconLabelWs,  ICON_WEBSOCKET);

	lv_obj_t *rightBody = lv_obj_create(p);
	lv_obj_remove_style_all(rightBody);
	lv_obj_set_align(rightBody, LV_ALIGN_TOP_RIGHT);
	lv_obj_set_size(rightBody, LV_SIZE_CONTENT, CONFIG_TOP_STATUS_BAR_HEIGHT);
	lv_obj_set_style_pad_right(rightBody, 10, 0);
	lv_obj_set_layout(rightBody, LV_LAYOUT_FLEX);
	lv_obj_set_pos(rightBody, 0, 2);
	lv_obj_set_style_flex_flow(rightBody, LV_FLEX_FLOW_ROW, 0);

	statusBarInfo = lv_label_create(rightBody);
	lv_obj_set_style_pad_right(statusBarInfo, 10, 0);
	lv_obj_set_style_text_color(statusBarInfo, LV_COLOR_WHITE, 0);
	lv_label_set_text(statusBarInfo,  "");
	lv_obj_set_style_text_align(statusBarInfo, LV_TEXT_ALIGN_LEFT, 0);

	statusBarCallSign = lv_label_create(rightBody);
	lv_obj_set_style_text_color(statusBarCallSign, LV_COLOR_WHITE, 0);
	lv_obj_set_style_text_align(statusBarCallSign, LV_TEXT_ALIGN_RIGHT, 0);
	lv_label_set_text(statusBarCallSign, stGroup[ST_CALL_SIGN].strValue);
	LVMG;
}

void statusBarIconStatus(char *icon, bool status) {
	lv_color_t c;
	if(status) {
		c = LV_COLOR_WHITE;
	}
	else {
		c = LV_COLOR_FONT_2;
	}
	if(strcmp(icon, "wifi") == 0) {
		LVMT;
		lv_obj_set_style_text_color(statusBarIconLabelWifi, c, 0);
		LVMG;
	}
	else if(strcmp(icon, "ws") == 0) {
		LVMT;
		lv_obj_set_style_text_color(statusBarIconLabelWs, c, 0);
		LVMG;
	}
}

void statusBarInfoUpdate(char *ip) {
	LVMT;
	lv_label_set_text(statusBarInfo, ip);
	LVMG;
}

#endif